﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="OAclient.Common" %>

<script type="text/javascript">
    function openWFCreate() {
        $.ajax({
            type: "GET",
            url: "/WorkFlow/WFCreate",
            success: function(data) {
                addtab('12-1', '新建流程');
                $("#workarea-12-1").html(data);
            }
        })
    }
    function openWFTypeList() {
        $.ajax({
            type: "GET",
            url: "/WorkFlow/WFTypeList",
            success: function(data) {
                addtab('12-3', '流程类型管理');
                $("#workarea-12-3").html(data);
            }
        })
    }
    $(function() {
        tableSelectOrder("#wfplatelist .table_style");
    })

    function checkProcedure(wftemplate_id) {
        $.ajax({
            type: "POST",
            url: "/WorkFlow/DoGetWFChart",
            data: { "wftemplate_id": wftemplate_id },
            success: function(data) {
                addtab("12-1-1", "审批流程图");
                var workarea = $("#workarea-12-1-1").html("<div id='procedure'></div>");
                var procedure = $(workarea).children("#procedure");
                var drag = $.fn.Procedure({ renderTo: procedure, inititedata: data });
            }
        });
    }
</script>

<div id="wfplatelist" style="padding-top: 5px;">
    <input class="btn_style" type="button" value="新建流程" onclick="openWFCreate()" />
    <input class="btn_style" type="button" value="流程类型管理" onclick="openWFTypeList()" />
    <div style="margin-top: 5px;">
        <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th>
                        编码
                    </th>
                    <th>
                        名称
                    </th>
                    <th>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                    System.Data.DataTable dt_plate = ViewData["dt_plate"] as System.Data.DataTable;
                    if (dt_plate == null || dt_plate.Rows.Count == 0)
                    { %>
                <tr>
                    <td colspan="0" style="text-align: center;">
                        当前无数据！
                    </td>
                </tr>
                <%}
                    else
                    {
                        for (int i = 0; i < dt_plate.Rows.Count; i++)
                        {
                %>
                <tr>
                    <td>
                        <%=dt_plate.Rows[i]["编码"]%>
                    </td>
                    <td>
                        <%=dt_plate.Rows[i]["名称"]%>
                    </td>
                    <td>
                        <a class='a_lookfor' onclick="checkProcedure(<%=dt_plate.Rows[i]["编码"] %>)">查看流程</a>
                    </td>
                </tr>
                <%
                    }
                    } %>
            </tbody>
        </table>
    </div>
</div>
<div id="pageLink">
    <%var pageInfo = ViewData["pageInfo"] as PagingInfo; %>
    <%if (pageInfo != null)
      { %>
    <%=Ajax.PageLinks(pageInfo, index => Url.Action("WFPlateList", new { page = index }), new AjaxOptions { UpdateTargetId = "workarea-12-2" })%>
    <%} %>
</div>
